package com.ssy.lingxi.order.controller.platform;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.api.model.vo.response.PlatformSettlementTypeVO;
import com.ssy.lingxi.order.service.base.IBaseCacheService;
import com.ssy.lingxi.order.service.platform.IPlatformSettlementTypeService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @menu 平台后台 - 结算支付方式相关接口实现类
 * @author 彭冬冬
 * @version 2.0.0
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/order/platform/settlement")
public class PlatformSettlementTypeController {
    @Resource
    private IPlatformSettlementTypeService service;

    @Resource
    private IBaseCacheService baseCacheService;

    /**
     * 获取所有启用的结算支付方式数据
     * @param headers 请求头
     * @return 平台结算支付方式列表
     */
    @RequestMapping(value = "/type/list", method = RequestMethod.GET)
    public Wrapper<List<PlatformSettlementTypeVO>> listSettlementType(@RequestHeader HttpHeaders headers) {
        // 1.校验登录信息
        baseCacheService.needLoginFromManagePlatform(headers);
        return service.findSettlementTypeByEnable();
    }

    /**
     * 获取所有启用的结算方式数据【账期、月结】
     * @param headers 请求头
     * @return 平台结算方式列表
     */
    @RequestMapping(value = "/category/list", method = RequestMethod.GET)
    public Wrapper<List<PlatformSettlementTypeVO>> listSettlementCategory(@RequestHeader HttpHeaders headers) {
        // 1.校验登录信息
        baseCacheService.checkUserFromCache(headers);
        return service.findSettlementCategoryByEnable();
    }

}
